package br.mil.eb.pqrmnt7.scc.entity.controleabastecimento;

import java.util.Date;

import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.annotations.ForeignKey;

import br.mil.eb.pqrmnt7.scc.entity.AppBaseEntity;

@MappedSuperclass
public abstract class LinhaControleSaldoCombustivel extends AppBaseEntity implements Comparable<LinhaControleSaldoCombustivel> {
	
	@Id 
 	@GeneratedValue(strategy=GenerationType.AUTO, generator = "SE_LINHA_CONTROLE_SALDO_COMBUSTIVEL")
	private Long id;
	
	@NotNull
	@Temporal(TemporalType.TIMESTAMP)
	private Date data;
	
	@NotNull
	@Digits(integer=10, fraction=0)
	private Long Entrada;
	
	@NotNull
	@Digits(integer=10, fraction=0)
	private Long Saida;
	
	@NotNull
	@Digits(integer=10, fraction=0)
	private Long saldo;
	
	@NotNull
	@Size(max = 40)
	private String viatura;
	
	@NotNull
	@Size(max = 40)
	private String motorista;
	
	@NotNull
	@Size(max = 10)
	private String numeroVale;
	
	@NotNull
	@Size(max = 40)
	private String fonte;

	@NotNull
	@Size(max = 40)
	private String tipoCombustivel;
	
	@ManyToOne (targetEntity = FluxoCombustivel.class, fetch = FetchType.LAZY)
	@ForeignKey(name="FK_LINHACONTROLESALDOCOMBUSTIVEL_FLUXO")
	@NotNull
	@Transient
	private FluxoCombustivel fluxoCombustivel;

	public String getMotorista() {
		return motorista;
	}

	public String getViatura() {
		return viatura;
	}

	public Long getEntrada() {
		return this.fluxoCombustivel != null ? this.fluxoCombustivel.getEntrada() : null;
	}

	public Long getSaida() {
		return this.fluxoCombustivel != null ? this.fluxoCombustivel.getSaida() : null;
	}

	public Long getSaldo() {
		return this.saldo;
	}
	
	public String getObservacao() {
		return this.fluxoCombustivel != null ? fluxoCombustivel.getObservacao() : null;
	}	
	
	public String getIdentificador() {
		return this.fluxoCombustivel != null ? this.fluxoCombustivel.getIdentificador() : null;
	}

	public Date getData() {
		return this.fluxoCombustivel != null ? this.fluxoCombustivel.getData() : null;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id=id;
	}

	public void setData(Date data) {
		this.data=data;
	}

	public void setEntrada(Long Entrada) {
		this.Entrada=Entrada;
	}

	public void setSaida(Long Saida) {
		this.Saida=Saida;
	}

	public void setSaldo(Long saldo) {
		this.saldo=saldo;
	}

	public void setViatura(String viatura) {
		this.viatura=viatura;
	}

	public void setMotorista(String motorista) {
		this.motorista=motorista;
	}

	public String getNumeroVale() {
		return numeroVale;
	}

	public void setNumeroVale(String numeroVale) {
		this.numeroVale=numeroVale;
	}

	public String getFonte() {
		return fonte;
	}

	public void setFonte(String fonte) {
		this.fonte=fonte;
	}

	public FluxoCombustivel getFluxoCombustivel() {
		return fluxoCombustivel;
	}

	public void setFluxoCombustivel(FluxoCombustivel fluxoCombustivel) {
		this.fluxoCombustivel=fluxoCombustivel;
	}

	public String getTipoCombustivel() {
		return this.fluxoCombustivel != null ? this.fluxoCombustivel.getTipoCombustivel().getNome() : null;
	}

	public void setTipoCombustivel(String tipoCombustivel) {
		this.tipoCombustivel = tipoCombustivel;
	}
	
}
